﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace Csharpzuoye
{
    //2.在Content之外封装一个方法，可以修改Content的CreateTime和PublishTime
    public class Time
    {
        public void GetCreateTime(Content content, DateTime dateTime)
        {
            typeof(Content)
           .GetProperty("CreateTime", BindingFlags.NonPublic | BindingFlags.Instance)
           .SetValue(content, dateTime);
            Console.WriteLine( );
        }
        public void GetPublishTime(Content content, DateTime dateTime)
        {
            typeof(Content)
           .GetProperty("PublishTime", BindingFlags.NonPublic | BindingFlags.Instance)
           .SetValue(content, dateTime);
            Console.WriteLine();
        }
    }
}
